import { WuXingConfig } from "../../resource/WuXingConfig";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { Alert } from "../../../../com/mui/controls/Alert";
import { Language } from "../../../../extend/language/Language";
import { MsgManager } from "../../manager/MsgManager";
import { WuXingSkillItem } from "./WuXingSkillItem";
import { GTextFormat } from "../../../common/GTextFormat";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ObjCreate } from "../common/ObjCreate";
import { WuXingPlayerInfo } from "../../model/wuxing/WuXingPlayerInfo";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../resource/ColorConfig";
type int = number;
//class WuXingSkillItem2
    
    export  class WuXingSkillItem2 /* flash.display.Sprite */
    {
        constructor(arg1: Object /* flash.display.MovieClip */, arg2: int, arg3: Boolean=true)
        {
            
            this._mc = arg1;
            this._index = arg2;
            this._showTxt = arg3;
            this.initUI();
            return;
        }

        /* internal  */onMouseClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=0;
            var loc2=0;
            if (!this._optAble) 
            {
                return;
            }
            if (this._info) 
            {
                loc1 = WuXingConfig.instance.getWXSkillByAttr(this._index, 1);
                loc2 = WuXingConfig.instance.getWXSkillNeedFightValue(loc1);
                if (this._info.mainAttribute != this._index) 
                {
                    if (this._info.skillAble) 
                    {
                        Dispatcher.dispatchEvent(new DataEvent(EventName.WuXingSkillChangeReq, this._index));
                    }
                    else 
                    {
                        Alert.show(Language.getStringByParam(26417, loc2), null, Alert.OK);
                    }
                }
                else if (!this._info.skillAble) 
                {
                    MsgManager.showRollTipsMsg(Language.getStringByParam(26393, loc2));
                }
            }
            return;
        }

        public set optAble(arg1: Boolean)
        {
            this._optAble = arg1;
            return;
        }

        protected initUI(): void
        {
            this._skillItem = new WuXingSkillItem(this._mc, this._index, false);
            addChild(this._skillItem);
            var loc1=new GTextFormat("", 12, GlobalStyle.color1);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._curAttrValue = ObjCreate.createTextField("", -18, 55, 90, 20, this, loc1);
            this._curAttrValue.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._curAttrValue.mouseEnabled = false;
            loc1 = new GTextFormat("", 12, GlobalStyle.color1);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._lockTxt = ObjCreate.createTextField("", -20, this._curAttrValue.y + 16, 100, 20, this, loc1);
            this._lockTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            loc1 = new GTextFormat("", 12, GlobalStyle.color1);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._effectTxt = ObjCreate.createTextField("", -20, this._lockTxt.y + 16, 100, 20, this, loc1);
            this._effectTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this.addEventListener(flash.events.MouseEvent.CLICK, this.onMouseClickHandler);
            if (this._showTxt) 
            {
                this._curAttrValue.y = 55;
                this._effectTxt.y = this._lockTxt.y + 16;
                this._lockTxt.visible = true;
            }
            else 
            {
                this._lockTxt.visible = false;
                this._curAttrValue.y = 7;
                this._effectTxt.y = 55;
            }
            return;
        }

        public updateData(arg1: WuXingPlayerInfo): void
        {
            this._info = arg1;
            if (this._info) 
            {
                this._skillItem.updateData(arg1);
                if (this._info.mainAttribute != this._index) 
                {
                    if (this._showTxt) 
                    {
                        this._curAttrValue.htmlText = HTMLUtil.addColor(Language.getString(26387) + this._info.getAttrValue(this._index), "#9CA0A1");
                    }
                    else 
                    {
                        this._curAttrValue.htmlText = HTMLUtil.addColor(this._info.getAttrValue(this._index).toString(), "#9CA0A1");
                    }
                    this._lockTxt.htmlText = HTMLUtil.addColor(Language.getString(26390), "#9CA0A1");
                    this._effectTxt.htmlText = HTMLUtil.addColor(this._info.getSkillEffectStr(this._index) + Language.getString(26388), "#9CA0A1");
                }
                else 
                {
                    if (this._showTxt) 
                    {
                        this._curAttrValue.htmlText = HTMLUtil.addColor(Language.getString(26387) + this._info.getAttrValue(this._index), "#02FBFF");
                    }
                    else 
                    {
                        this._curAttrValue.htmlText = HTMLUtil.addColor(this._info.getAttrValue(this._index).toString(), "#02FBFF");
                    }
                    this._effectTxt.htmlText = HTMLUtil.addColor(this._info.getSkillEffectStr(this._index) + Language.getString(26388), ColorConfig.instance.getWuxingColor(this._index));
                    if (this._info.skillAble) 
                    {
                        this._lockTxt.htmlText = HTMLUtil.addColor(Language.getString(26389), "#ffff00");
                    }
                    else 
                    {
                        this._lockTxt.htmlText = HTMLUtil.addColor(Language.getString(26390), "#ffff00");
                    }
                }
            }
            return;
        }

        public get index(): int
        {
            return this._index;
        }

        /* internal */ /* var */_info: WuXingPlayerInfo;

        /* internal */ /* var */_showTxt: Boolean;

        /* internal */ /* var */_mc: Object /* flash.display.MovieClip */;

        /* internal */ /* var */_index: int;

        /* internal */ /* var */_skillItem: WuXingSkillItem;

        /* internal */ /* var */_curAttrValue: Object /* flash.text.TextField */;

        /* internal */ /* var */_lockTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_effectTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_optAble: Boolean=true;
    }
